#ifndef DATACENTER_H
#define DATACENTER_H

#include <QObject>
#include "../network/netclient.h"

namespace model {
class InterviewInfo;
class CompanyInfo;
class QuestionClusterInfo;
class QuestionInfo;
class UserInfo;
class SearchLimits;
}

namespace quan_mian {
class SearchInterviewRsp;
class SearchQuestionClusterRsp;
class SearchCompanyRsp;
}

namespace model {

class DataCenter : public QObject
{
    Q_OBJECT

private:
    DataCenter() {}
    DataCenter(const DataCenter&) = delete;
    DataCenter& operator=(const DataCenter&) = delete;

public:
    static DataCenter& getInstance() {
        static DataCenter instance;
        return instance;
    }

    void ping() { _netClient.ping(); }

    UserInfo* getMyself();

    void searchInterviewAsync(const SearchLimits &limits);
    QList<InterviewInfo>* getSearchInterviewResult();
    void resetSearchInterviewResult(std::shared_ptr<quan_mian::SearchInterviewRsp> rsp);

    void searchQuestionClusterAsync(const SearchLimits &limits);
    QList<QuestionClusterInfo>* getSearchQuestionClusterResult();
    void resetSearchQuestionClusterResult(std::shared_ptr<quan_mian::SearchQuestionClusterRsp> rsp);

    void searchCompanyAsync(const SearchLimits &limits);
    QList<CompanyInfo>* getSearchCompanyResult();
    void resetSearchCompanyResult(std::shared_ptr<quan_mian::SearchCompanyRsp> rsp);

    void uploadInterviewAsync(const InterviewInfo &interview);

signals:
    void searchInterviewDone();
    void searchQuestionClusterDone();
    void searchCompanyDone();
    void uploadInterviewDone();

private:
    UserInfo* _myself = nullptr;

    QList<InterviewInfo>* _searchInterviewResult = nullptr;

    QList<QuestionClusterInfo>* _searchQuestionClusterResult = nullptr;

    QList<CompanyInfo>* _searchCompanyResult = nullptr;

    network::NetClient _netClient;
};

}

#endif // DATACENTER_H
